Skip to content

feat(memtrack): support disabling allocator tracking - #469

Merged
not-matthias merged 1 commit into
mainfrom
cod-3231-support-disabling-allocator-tracking
Aug 28, 2026
Merged

feat(memtrack): support disabling allocator tracking#469
not-matthias merged 1 commit into
mainfrom
cod-3231-support-disabling-allocator-tracking

Conversation

@not-matthias

@not-matthias not-matthias commented Jul 24, 2026

Copy link
Copy Markdown
Member

What

memtrack track --track-allocators (default on, env CODSPEED_TRACK_ALLOCATORS). When disabled, memtrack skips the allocator uprobe machinery and only emits coarse mmap/munmap/brk events.

Why

Allocation-heavy programs (e.g. a Rust build) generate an overwhelming number of malloc/free events, and the per-allocation uprobes slow the target significantly. This trades allocation granularity for lower overhead while still collecting RSS-relevant memory events.

How

  • mmap/munmap/brk syscall tracepoints are now always attached in a memory run.
  • With the flag off, the exec watcher and allocator attach worker are never started.
  • No runner CLI flag: the env var is inherited by the memtrack subprocess, keeping the runner decoupled from the installed memtrack version.

@greptile-apps

greptile-apps Bot commented Jul 24, 2026

Copy link
Copy Markdown

Greptile Summary

Adds an allocator-tracking toggle for memtrack.

  • Introduces explicit tracker options backed by CODSPEED_MEMTRACK_TRACK_ALLOCATORS.
  • Keeps mmap, munmap, and brk tracepoints active when allocator probes are disabled.
  • Skips the executable-mapping watcher and allocator attach worker in coarse tracking mode.
  • Adds integration coverage for syscall events without allocator events.

Confidence Score: 5/5

The PR appears safe to merge because no blocking failures eligible for this follow-up review remain.

No blocking failure remains.

Important Files Changed

Filename Overview
crates/memtrack/src/ebpf/tracker.rs Adds environment-backed tracker options and conditionally starts allocator discovery machinery.
crates/memtrack/src/ebpf/memtrack/tracking.rs Attaches mmap, munmap, and brk syscall tracepoints for every memory-tracking run.
crates/memtrack/tests/c_tests.rs Verifies that disabling allocator tracking retains mmap events while suppressing allocator events.
crates/memtrack/tests/shared.rs Adds option-based test helpers and limits allocation snapshots to deterministic allocator events.
crates/memtrack/Cargo.toml Adds typed-builder for constructing tracker options.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Create Tracker] --> B[Attach lifecycle and memory syscall tracepoints]
  B --> C{Allocator tracking enabled?}
  C -->|Yes| D[Attach executable-mapping watcher]
  D --> E[Start allocator attach worker]
  C -->|No| F[Skip watcher and attach worker]
  E --> G[Collect allocator and mmap/munmap/brk events]
  F --> H[Collect mmap/munmap/brk events only]
Loading

Reviews (5): Last reviewed commit: "feat: add --track-allocators toggle for ..." | Re-trigger Greptile

@codspeed-hq

codspeed-hq Bot commented Jul 24, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

✅ 17 untouched benchmarks


Comparing cod-3231-support-disabling-allocator-tracking (6ecb3c0) with main (4ea6774)

Open in CodSpeed

@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch 2 times, most recently from d983261 to 131f8a3 Compare July 24, 2026 10:40
@not-matthias
not-matthias changed the base branch from main to cod-3089-collect-rss-in-memtrack July 24, 2026 12:04

@GuillaumeLagrange GuillaumeLagrange left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what's really the usecase of this? olgtm but I'm not sure we've discussed

Comment thread crates/memtrack/src/main.rs Outdated
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch 2 times, most recently from f1dbc8a to efc66c8 Compare July 30, 2026 10:48
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from 7e96222 to bdd0455 Compare July 30, 2026 12:40
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from bdd0455 to e158870 Compare July 30, 2026 15:35
@not-matthias not-matthias changed the title feat: add --track-allocators toggle for memory mode feat(memtrack): support disabling allocator tracking Aug 18, 2026
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from e158870 to bbff5ff Compare August 20, 2026 08:25
Base automatically changed from cod-3089-collect-rss-in-memtrack to main August 24, 2026 09:43
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from bbff5ff to 0a48795 Compare August 24, 2026 12:34

@GuillaumeLagrange GuillaumeLagrange left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

olgtm

Comment thread crates/memtrack/src/ebpf/tracker.rs Outdated
Comment thread crates/memtrack/src/ebpf/tracker.rs Outdated
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch 3 times, most recently from 2cdf777 to 5ef554a Compare August 28, 2026 16:57
Add a --track-allocators flag (default on, env CODSPEED_TRACK_ALLOCATORS)
to the memtrack track subcommand. When disabled, memtrack skips the
allocator uprobe machinery (exec watcher + attach worker) and only emits
coarse mmap/munmap/brk events, reducing overhead on allocation-heavy
programs. The mmap/munmap/brk syscall tracepoints are now always attached
in every memory run.

The runner does not add a CLI flag for this: it relies on the
CODSPEED_TRACK_ALLOCATORS environment variable being inherited by the
memtrack subprocess, keeping the runner decoupled from the installed
memtrack version. Standalone memtrack can still use the CLI flag.
@not-matthias
not-matthias force-pushed the cod-3231-support-disabling-allocator-tracking branch from 5ef554a to 6ecb3c0 Compare August 28, 2026 17:46
@not-matthias
not-matthias merged commit 6ecb3c0 into main Aug 28, 2026
48 checks passed
@not-matthias
not-matthias deleted the cod-3231-support-disabling-allocator-tracking branch August 28, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants